<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>判断一个数字是否可以表示成三的幂的和</title>
</head>
<body>
  <script>
    function fn(n) {
      while (n !== 0) {
        if (n % 3 === 2) return false;
        n = Math.floor(n / 3);
      }
      return true
    }
    console.log(fn(12))
  </script>
</body>
</html>